﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;
using Model;
using System.Data;
using System.Data.SqlClient;
using Word = Microsoft.Office.Interop.Word;
using System.IO;
using System.Reflection;
using System.Windows.Forms;

namespace NCRE学生考试端V1._0
{

    public   class WordAFontInstall
    {

        private static Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
        private static object unknow = Type.Missing;
        private static object file = @"D:\" + MyInfo.MystudentID() + @"\计算机一级考生文件\"+MyInfo.MyPaperType().Trim() + "卷\\Wordkt\\Word"+ MyInfo.MyPaperType().Trim()+".docx";
        private readonly Microsoft.Office.Interop.Word.Document doc = app.Documents.Add(ref file, ref unknow, ref unknow, ref unknow);
        private static WordQuestionEntityBll wordquestionbll = new WordQuestionEntityBll();
        private readonly WordQuestionEntity wordinfo = new WordQuestionEntity();
        readonly WordLoadinfo gonggong = new WordLoadinfo();

        #region 王荣晓 标题字体间距  修改人：于云秀 2018年4月24日08:16:08
        /// <summary>
        /// 标题字体间距
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontSpaceInstallB(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag like '%标题字体间距%'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Spacing.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion


        #region 王荣晓 标题字体型号设计-程金鹏修改-2018年4月22日20:42:12
        /// <summary>
        /// 字体设置：标题字体型号设计
        /// 
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontNameInstall(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='标题字体型号'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.NameFarEast.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 标题字体颜色设置-程金鹏修改-2018年4月22日20:44:02
        /// <summary>
        /// 标题字体颜色设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontColorInstall(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='标题字体颜色'");

            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();

            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.ColorIndex.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);

            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 标题字体加粗设置-程金鹏修改-2018年4月22日20:45:00
        /// <summary>
        /// 标题字体加粗设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontBoldInstall(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='标题字体加粗'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Bold.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);

            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }
        #endregion

        #region 王荣晓 标题字体大小设置-程金鹏修改-2018年4月22日
        /// <summary>
        /// 标题字体大小设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontSizeInstall(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='标题字体大小'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Size.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来  
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);

            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 标题字符间距-程金鹏修改-2018年4月22日20:49:37
        /// <summary>
        /// 标题字符间距
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontSeparationInstall(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            //调出根据问题标识和试卷类型查出的信息
            DataRow[] drs_word = dt.Select("QuestionFlag='标题字符间距'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Spacing.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来                
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分，是否加分
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }
        #endregion

        #region 王荣晓 标题字体对齐方式设置-程金鹏修改-2018年4月22日20:52:54
        /// <summary>
        /// 标题字体对齐方式设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontAlignInstall(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='标题字体对齐方式'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();

            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Alignment.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来     
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分，是否加分
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }
        #endregion

        #region 王荣晓 正文字体型号设置-程金鹏修改-2018年4月22日21:26:20

        /// <summary>
        /// 正文字体型号设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void MainTextSet(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='正文字体型号'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();

            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;

            studentrecord.TimeStamp = MyInfo.TimeTamp();
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.NameFarEast.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来   
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分，是否加分
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }

        #endregion

        #region 王荣晓 正文字体大小-程金鹏修改-2018年4月22日21:27:50
        /// <summary>
        /// 正文字体大小
        /// </summary>
        /// <param name="wordinfo"></param>
        public void MainTextSizeSet(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='正文字体大小'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();

            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;

            studentrecord.TimeStamp = MyInfo.TimeTamp();
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Size.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来 
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分，是否加分
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }

        #endregion

        #region 王荣晓 正文格式
        /// <summary>
        /// 正文格式
        /// </summary>
        /// <param name="wordinfo"></param>
        public void MainTextFormatSet(WordQuestionEntity wordinfo, DataTable dt)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='正文格式'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            //将考生答案传递给studentrecord实体
            studentrecord.ExamAnswer = app.Selection.ParagraphFormat.Alignment.ToString();
            //将试题的ID选择出来      
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分，是否加分
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }

        #endregion

        #region 王荣晓 正文行距-程金鹏修改-2018年4月22日21:28:43
        /// <summary>
        /// 正文行距
        /// </summary>
        /// <param name="wordinfo"></param>
        public void SpacingFormatSet(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='正文行距'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;

            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].LineSpacing.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来            
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分，是否加分
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }

        #endregion

        #region  王荣晓 删除空格 修改人：于云秀  2018年4月24日08:30:27
        /// <summary>
        /// 删除空格
        /// </summary>
        /// <param name="studentinfo"></param>
        public void DeleteBlankWordC(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_StringStartIndex, Int32 Para_StringLength)
        {

            //将正确答案、分值取出来，传给dt
            wordinfo.QuestionFlag = "删除空格";
            DataRow[] drs_word = dt.Select("QuestionFlag='删除空格'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;

            if (doc.Content.Text.Trim().Length >= Para_StringStartIndex + Para_StringLength)
            {
                //将考生答案传递给studentrecord实体
                studentrecord.ExamAnswer = doc.Content.Text.Trim().Substring(Para_StringStartIndex, Para_StringLength);
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }


            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion



        #region 王荣晓 标题字体对齐方式设置  修改人：于云秀  2018年4月24日08:41:32
        /// <summary>
        /// 标题字体对齐方式设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontAlignInstallC(WordQuestionEntity wordinfo, System.Data.DataTable dt)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='标题格式'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            //将考生答案传递给studentrecord实体
            studentrecord.ExamAnswer = app.Selection.ParagraphFormat.Alignment.ToString();
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 小标题字体对齐方式设置  修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 小标题字体对齐方式设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void LittleFontAlignInstallC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='小标题格式'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Alignment.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 小标题字体型号设计  修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 字体设置：小标题字体型号设计
        /// 
        /// </summary>
        /// <param name="wordinfo"></param>
        public void LittleFontNameInstallC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='小标题字体型号'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.NameFarEast.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 小标题字体颜色设置  修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 小标题字体颜色设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void LittleFontColorInstallC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='小标题字体颜色'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.ColorIndex.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 小标题字体大小设计  修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 字体设置：小标题字体大小设计
        /// 
        /// </summary>
        /// <param name="wordinfo"></param>
        public void LittleFontSizeInstallC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='小标题字体大小'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Size.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }
        #endregion

        #region 王荣晓 小标题字体加粗设置  修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 小标题字体加粗设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void LittleFontBoldInstallC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_Pargraphs)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='小标题字体加粗'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.Bold.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 小标题段前段后   修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 小标题段前段后
        /// </summary>
        /// <param name="wordinfo"></param>
        public void TittleAlignSetC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='小标题段前段后'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.ParagraphFormat.SpaceBefore.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }

        #endregion

        #region 王荣晓 标题字体格式  修改人：于云秀  2018年4月24日11:19:43
        /// <summary>
        /// 标题字体格式
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontAlignInstallB(WordQuestionEntity wordinfo, DataTable dt)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag like '%标题字体格式%'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= 2)
            {
                if (doc.Paragraphs[2].Range.Text.Trim() != "\r" || doc.Paragraphs[2].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[2].Alignment.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            if (drs_word.Count() == 0)
            {
                return;
            }
            //将试题的ID选择出来
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 王荣晓 图片宽高   修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 图片宽高
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FindPictureHightC(WordQuestionEntity wordinfo, System.Data.DataTable dt, Int32 Para_PictureID)
        {
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();

            DataRow[] drs_word = dt.Select("QuestionFlag='图片宽高'");
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            if (doc.Shapes.Count == 0)
            {
                //如果表格不存在，则判分为0
                studentrecord.StudentID = FrmLogin.studentID;
                studentrecord.ExamAnswer = "0";
                studentrecord.Fration = "0";
                //将答题记录送到数据库
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
                }
                WordLoadinfo.list.Add(studentrecord);

            }
            else
            {
                //传递考生ID进studentrecord实体
                studentrecord.StudentID = FrmLogin.studentID;

                //将考生答案传递给studentrecord实体

                studentrecord.ExamAnswer = doc.Shapes[Para_PictureID].Height.ToString() + doc.Shapes[Para_PictureID].Width.ToString();

                //将试题的ID选择出来
                if (drs_word.Count() == 0)
                {
                    return;
                }
                studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
                //判分
                WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));


            }


        }
        #endregion

        #region 王荣晓 正文字体加粗  修改人：于云秀  2018年4月24日08:43:36
        /// <summary>
        /// 正文字体加粗
        /// </summary>
        /// <param name="wordinfo"></param>
        public void MainTextBoldSetB(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag like '%正文字体加粗%'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.BoldBi.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }

        #endregion

        #region 李少然 正文字体格式  修改人：于云秀 2018年4月24日08:21:26
        /// <summary>
        /// 正文字体格式
        /// </summary>
        /// <param name="wordinfo"></param>
        public void MainTextFormatSetF(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='正文字体格式'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递考生ID进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() == "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() == "")
                {
                    studentrecord.ExamAnswer = "空答案";
                }
                else
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].RightIndent.ToString();
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            //将试题的ID选择出来
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }

        #endregion

        #region 李少然 标题文字底纹  修改人：于云秀 2018年4月24日08:21:26
        /// <summary>
        /// 标题文字底纹
        /// </summary>
        /// <param name="wordinfo"></param>
        public void TiTleCaptionShadingE(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='标题文字底纹'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递时间戳进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Font.UnderlineColor.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }

            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }
        #endregion

        #region 李少然 标题段前段后设置  修改人：于云秀 2018年4月24日08:21:26
        /// <summary>
        /// 标题段前段后设置
        /// </summary>
        /// <param name="wordinfo"></param>
        public void FontParagraphInstallE(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='标题段前段后'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递时间戳进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() != "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() != "")
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.ParagraphFormat.SpaceAfter.ToString();
                }
                else
                {
                    studentrecord.ExamAnswer = "空答案";
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));
        }
        #endregion

        #region 李少然 小标题格式 修改人：于云秀 2018年4月24日08:21:26
        /// <summary>
        /// 小标题段格式
        /// </summary>
        /// <param name="wordinfo"></param>
        public void LittleRightIndentSetE(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs)
        {
            DataRow[] drs_word = dt.Select("QuestionFlag='小标题字体格式'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            //传递时间戳进studentrecord实体
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() == "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() == "")
                {
                    studentrecord.ExamAnswer = "空答案";
                }
                else
                {
                    //将考生答案传递给studentrecord实体
                    studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].RightIndent.ToString();
                }
                //将试题的ID选择出来
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }

        #endregion


        #region 李少然 标题文字 修改人：于云秀 2018年4月24日08:21:26
        /// <summary>
        /// 标题文字
        /// 
        /// </summary>
        /// <param name="wordinfo">题库实体</param>
        public void TiTleFontH(WordQuestionEntity wordinfo, DataTable dt, Int32 Para_Pargraphs, Int32 Para_StringStartIndex, Int32 Para_StringLength)
        {

            DataRow[] drs_word = dt.Select("QuestionFlag='标题文字'");
            WordQuestionRecordEntity studentrecord = new WordQuestionRecordEntity();
            studentrecord.TimeStamp = MyInfo.TimeTamp();
            //传递考生ID进studentrecord实体
            studentrecord.StudentID = FrmLogin.studentID;
            if (doc.Paragraphs.Count >= Para_Pargraphs)
            {
                if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim() == "\r" || doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().ToString() == "")
                {
                    studentrecord.ExamAnswer = "空答案";
                }
                else
                {
                    if (doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().Length >= Para_StringLength)
                    {
                        //将考生答案传递给studentrecord实体
                        studentrecord.ExamAnswer = doc.Paragraphs[Para_Pargraphs].Range.Text.Trim().Substring(Para_StringStartIndex, Para_StringLength);


                    }
                    else
                    {
                        studentrecord.ExamAnswer = "空答案";
                    }
                }
            }
            else
            {
                studentrecord.ExamAnswer = "空答案";
            }
            //将试题的ID选择出来
            if (drs_word.Count() == 0)
            {
                return;
            }
            studentrecord.QuestionID = Convert.ToDouble(drs_word[0]["QuestionID"]);
            //判分         
            WordLoadinfo.list.Add(gonggong.getStudentRecord(drs_word, studentrecord));

        }
        #endregion
    }
}
   